﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Media;
namespace MegavaniaX.Music
{
    internal class MusicManager
    {
        private Song currentSong;
        private bool DoPlayMusic = false;
        private ContentManager _contentManager;

        public MusicManager(ContentManager contentManager)
        {
            _contentManager = contentManager;
        }

        internal void PlayMusic(string songname)
        {
            if (DoPlayMusic)
            {
                currentSong = _contentManager.Load<Song>(songname);
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play(currentSong);
            }
        }

        internal void PauseMusic()
        {
            MediaPlayer.Pause();
        }

        internal void UnpauseMusic()
        {
            MediaPlayer.Resume();
        }

        internal void StopMusic()
        {
            MediaPlayer.Stop();
            if (currentSong != null && !currentSong.IsDisposed)
            {
                currentSong.Dispose();
            }
        }

        internal void DisposeAll()
        {           
            if (currentSong != null && !currentSong.IsDisposed)
            {
                currentSong.Dispose();
            }
        }

    }
}
